package cn.wolfcode.rbac.service.impl;

import cn.wolfcode.rbac.domain.Department;
import cn.wolfcode.rbac.domain.SystemDictionary;
import cn.wolfcode.rbac.domain.SystemDictionaryItem;
import cn.wolfcode.rbac.mapper.DepartmentMapper;
import cn.wolfcode.rbac.mapper.SystemDictionaryMapper;
import cn.wolfcode.rbac.query.PageResult;
import cn.wolfcode.rbac.query.QueryObject;
import cn.wolfcode.rbac.service.IDepartmentService;
import cn.wolfcode.rbac.service.ISystemDictionaryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SystemDictionaryServiceImpl implements ISystemDictionaryService {
    @Autowired
    private SystemDictionaryMapper systemDictionaryMapper;

    @Override
    @Transactional(readOnly = true)
    public PageInfo query(QueryObject paramQueryObject) {
        PageHelper.startPage(paramQueryObject.getCurrentPage(), paramQueryObject.getPageSize());
        List<SystemDictionary> list = this.systemDictionaryMapper.selectForList(paramQueryObject);
        return new PageInfo(list);
    }

    @Override
    public void saveOrUpdate(SystemDictionary systemDictionary) {
        if (systemDictionary.getId() == null) {
            this.systemDictionaryMapper.insert(systemDictionary);
        } else {
            this.systemDictionaryMapper.updateByPrimaryKey(systemDictionary);
        }
    }

    @Override
    public void delete(Long paramLong) {
        this.systemDictionaryMapper.deleteByPrimaryKey(paramLong);
    }

    @Override
    @Transactional(readOnly = true)
    public SystemDictionary get(Long paramLong) {

        return this.systemDictionaryMapper.selectByPrimaryKey(paramLong);
    }

    @Override
    @Transactional(readOnly = true)
    public List<SystemDictionary> list() {
        List<SystemDictionary> systemDictionarys = this.systemDictionaryMapper.selectAll();
        return systemDictionarys;
    }


}
